package com.aegean.MonitorExamSYS.conduction.action;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.aegean.MonitorExamSYS.conduction.business.ConductionBusiness;
import com.aegean.MonitorExaxSYS.model.ConductionValue;
import com.opensymphony.xwork2.ActionSupport;

@Controller("ApplyForQualification")
@Scope("prototype")
public class ApplyForQualification extends ActionSupport {
	@Resource
	ConductionBusiness business;
	private int exam_Id;
	private int state;
	private boolean success;
	private String msg;

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}

	public int getExam_Id() {
		return exam_Id;
	}

	public void setExam_Id(int exam_Id) {
		this.exam_Id = exam_Id;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		HttpSession session = (HttpSession) ServletActionContext.getRequest()
				.getSession();
		ConductionValue conduction = (ConductionValue) session
				.getAttribute("ConductionLogin");
		success = business.applyForQualification(state,
				conduction.getConduction_Id(), exam_Id);
		if (success == true) {
			msg = "申请已经发到考试中心，请耐心等待考试中心的回复！";
		} else {
			msg = "对不起，您已经对该考试申请过，请耐心等待考试中心的回复!";
		}
		return SUCCESS;
	}

}
